package com.yeepay.skb.biz;


import com.yeepay.skb.util.Conts;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 子商户费率设置接口
 */
public class FeeSetPartsBuilder extends YeepayBuilder{

    protected List<Part> parts = new ArrayList<Part>(11);
    protected String url= Conts.baseRequestUrl + "/feeSetApi.action";
    private ArrayList<String> needHmac=new ArrayList<>(Arrays.asList(
            "customerNumber",
            "mainCustomerNumber",
            "productType",
            "rate"));

    public Part[] generateParams() {
        return parts.toArray(new Part[parts.size()]);
    }


    public FeeSetPartsBuilder setCustomerNumber(String customerNumber) {
        this.parts.add(new StringPart("customerNumber", customerNumber == null ? "" : customerNumber, "UTF-8"));
        return this;
    }

    public FeeSetPartsBuilder setGroupCustomerNumber(String groupCustomerNumber) {
        this.parts.add(new StringPart("mainCustomerNumber", groupCustomerNumber == null ? ""
                : groupCustomerNumber, "UTF-8"));
        return this;
    }

    public FeeSetPartsBuilder setProductType(String productType) {
        this.parts.add(new StringPart("productType", productType == null ? ""
                : productType, "UTF-8"));
        return this;
    }

    public FeeSetPartsBuilder setRate(String rate) {
        this.parts.add(new StringPart("rate",
                rate == null ? "" : rate, "UTF-8"));
        return this;
    }

    public FeeSetPartsBuilder setCfca(String cfca) {
        this.parts
                .add(new StringPart("cfca", cfca == null ? "" : cfca, "UTF-8"));
        return this;
    }

    public void setHmac(String hmac) {
        this.parts
                .add(new StringPart("hmac", hmac == null ? "" : hmac, "UTF-8"));
    }

    @Override
    public List<String> needHmacArr() {
        return needHmac;
    }

    public List<Part> getParts() {
        return parts;
    }

    @Override
    public String getUrl() {
        return url;
    }
}
